package br.com.swp.campestre.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Version;

import org.hibernate.validator.Length;

@Entity
public class Cidade implements Serializable
{
    // seam-gen attributes (you should probably edit these)
    private Long id;
    private Integer version;
    private String nome;
    private String siglaUf;
    private UF uf;
    

    // add additional entity attributes

    // seam-gen attribute getters/setters with annotations (you probably should edit)
    
    public Cidade(){
    	
    }
    
    public Cidade(Long id, Integer version, String nome, String siglaUf, Long id_uf , String nome_uf, String sigla_uf ){
    	this.id = id;
    	this.version = version;
    	this.nome = nome;
    	this.siglaUf = siglaUf;
    	
    	this.setUf(new UF());
    	this.getUf().setId(id_uf);
    	this.getUf().setNome(nome_uf);
    	this.getUf().setSigla(sigla_uf);
    	
    }

	@Id @GeneratedValue
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Version
    public Integer getVersion() {
        return version;
    }

    private void setVersion(Integer version) {
        this.version = version;
    }

    @Length(max = 50)
    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Cidade other = (Cidade) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@ManyToOne
	public UF getUf() {
		return uf;
	}

	public void setUf(UF uf) {
		this.uf = uf;
	}

	@Column(name="sigla_uf")
	public String getSiglaUf() {
		return siglaUf;
	}

	public void setSiglaUf(String siglaUf) {
		this.siglaUf = siglaUf;
	}

}
